<template>
	<view v-if="orderInfo" style="overflow-x: hidden;">
		<view class="nav-back m-b16">
			<top-heigth backTitle="订单详情"></top-heigth>
		</view>	
		
		<!-- 取消按钮 -->
		<view>
			<uv-modal ref="modal" title="" align="center"
				content='是否确认取消售后' 
				showCancelButton @confirm="confirm">
			</uv-modal>
		</view>
		
		<view class="content-box m-b16">
			<view class="public-box" style="padding-bottom: 0; overflow: hidden;">
				<view class="complaint-top">
					<view class="complaint-top-img">
						<view>订单编号：{{orderInfo.orderCode}}</view>
					</view>
					 <!-- orange red blue 灰色为空  技师拒单为6-->
					<view v-if="orderInfo.orderStatus == 0" class="complaint-top-r orange">订单状态：待接单</view>
					<view v-if="orderInfo.orderStatus == 1" class="complaint-top-r red">订单状态：待服务</view>
					<view v-if="orderInfo.orderStatus == 2" class="complaint-top-r red">订单状态：已完成</view>
					<view v-if="orderInfo.orderStatus == 3" class="complaint-top-r red">订单状态：申请退款</view>
					<view v-if="orderInfo.orderStatus == 4" class="complaint-top-r">订单状态：退款成功</view>
					<view v-if="orderInfo.orderStatus == 5" class="complaint-top-r blue">订单状态：拒绝退款</view>
					<view v-if="orderInfo.orderStatus == 6" class="complaint-top-r blue">订单状态：技师拒单</view>
					<view v-if="orderInfo.orderStatus == 7" class="complaint-top-r blue">订单状态：已关闭</view>
					<view v-if="orderInfo.orderStatus == 8" class="complaint-top-r blue">订单状态：取消退款</view>
					<view v-if="orderInfo.orderStatus == 10" class="complaint-top-r blue">订单状态：待支付</view>
				</view>
				
				<view class="goods-box">
					<view class="goods">
						<view class="img-box">
							<image class="img" :src="orderInfo.tAppServiceVo.serviceImage" mode="widthFix"></image>
						</view>
						<view class="goods-font">
							<view class="start-top">
								<h1 class="goods-h1 start-h1">{{orderInfo.tAppServiceVo.serviceName}}</h1>
							</view>
							<view class="sale">预约时间：{{orderInfo.serviceReservedTime}}</view>
						</view>
					</view>
				</view>
				


				<view v-if="orderInfo.orderStatus != 5" class="">
					<view class="detail-font">
						<view class="left">实付金额</view>
						<view class="right red">{{orderInfo.orderAmount}}</view>
					</view>
					<view class="detail-font">
						<view class="left">商品总价</view>
						<view class="right">{{orderInfo.tAppServiceVo.serviceAmount}}</view>
					</view>
					<view class="detail-font">
						<view class="left">交通费</view>
						<view class="right">{{orderInfo.postAmount != null ? orderInfo.postAmount : "无"}}</view>
					</view>
					<view class="detail-font">
						<view class="left">优惠券</view>
						<view class="right">{{orderInfo.tAppCouponUserVo ? orderInfo.tAppCouponUserVo.tAppCouponVo.couponAmount : 0}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view v-if="orderInfo.orderStatus == 3||orderInfo.orderStatus == 4||orderInfo.orderStatus == 5" class="content-box m-b16">
			<view class="public-box order-tui">
				<h1 class="order-h1">退款理由</h1>
				<view class="order-h1-font">{{orderInfo.refuseRemark}}</view>
			</view>
		</view>
		<view v-if="orderInfo.orderStatus == 3||orderInfo.orderStatus == 4||orderInfo.orderStatus == 5" class="content-box m-b16">
			<view class="public-box order-tui">
				<h1 class="order-h1">退款原因</h1>
				<view class="order-h1-font">{{refundOption}}</view>
			</view>
		</view>
		<view v-if="orderInfo.orderStatus == 5" class="content-box m-b16">
			<view class="public-box order-tui">
				<h1 class="order-h1">商家拒绝退款</h1>
				<view class="order-h1-font">{{orderInfo.refuseReason}}</view>
			</view>
		</view>
		
		<view v-if="orderInfo.orderStatus == 4" class="content-box m-b16">
			<view class="public-box order-tui">
				<h1 class="order-h1">商家同意退款</h1><!-- 固定文案 -->
				<view class="order-h1-font">您的订单商家已同意退款，钱款将原路返回</view>
			</view>
		</view>
		
		<view class="content-box m-b16">
			<view class="public-box" style="padding-bottom: 0; overflow: hidden;">
				<h1 class="order-h1">订单详情</h1>
				<view class="">
					<view class="detail-font2">
						<view class="left">技师姓名：</view> 
						<view class="right">{{orderInfo.tAppStaffVo.staffName}}</view>
					</view>
					<view class="detail-font2">
						<view class="left">联系人：</view>
						<view class="right">{{orderInfo.userName}}  <!-- 这个地址不应该是选的地址吗 --> 
							（<span v-if="orderInfo.tAppUserVo.userSex == 1">先生</span>
							<span v-else>女士</span>）
						</view>
					</view>
					<view class="detail-font2">
						<view class="left">联系电话：</view>
						<view class="right">{{orderInfo.userMobile}}</view>
					</view>
					<view v-if="orderInfo.serviceReservedTime != null" class="detail-font2">
						<view class="left">服务时间:</view>
						<view class="right">{{orderInfo.serviceReservedTime}}</view>
					</view>
					<view class="detail-font2">
						<view class="left">服务地址：</view>
						<view class="right">{{orderInfo.userAddress}}</view>
					</view>
					<view class="detail-font2">
						<view class="left">下单时间：</view>
						<view class="right">{{orderInfo.createTime}}</view>
					</view>
					<!-- 待接单 和 技师拒单不显示
					  v-if="orderInfo.orderStatus != 0||orderInfo.orderStatus != 6 ||orderInfo.orderStatus != null"
					 -->
					<view v-if="orderInfo.staffTakeTime != null" class="detail-font2">
						<view class="left">技师接单时间:</view>
						<view class="right">{{orderInfo.staffTakeTime}}</view>
					</view>
					<view class="detail-box" v-if="orderInfo.clockTime != '' && orderInfo.clockTime != null">
							<view class="detail-font2">
								<view class="left">打卡时间：</view>
								<view class="right">{{orderInfo.clockTime}}</view>
							</view>
						</view>
					    <view class="detail-box" v-if="orderInfo.clockImg">
					    <view class="detail-font2">
						    <view class="left">打卡图片</view>
								
					    </view>
						
					</view>
						<image class="img-b" v-if="orderInfo.clockImg" :src="orderInfo.clockImg" mode=""></image>
						
					<!-- 待接单 和 待服务 技师拒单 不显示
						v-if="orderInfo.orderStatus != 0||orderInfo.orderStatus != 1||orderInfo.orderStatus != 6"
					 --> 
					<view v-if="orderInfo.serviceStartTime != null" class="detail-font2">
						<view class="left">开始服务时间:</view>
						<view class="right">{{orderInfo.serviceStartTime}}</view>
					</view>
					<!-- 待接单 和 待服务 技师拒单 不显示
						v-if="orderInfo.orderStatus != 0||orderInfo.orderStatus != 1||orderInfo.orderStatus != 6"
					 --> 
					<view v-if="orderInfo.serviceEndTime != null" class="detail-font2">
						<view class="left">服务完成时间:</view>
						<view class="right">{{orderInfo.serviceEndTime}}</view>
					</view>
					
					<view class="detail-font2">
						<view class="left">订单备注：</view>
						<view>{{orderInfo.orderRemark || '无'}}</view>
					</view>
					<!-- 申请售后 显示 -->
					<view  v-if="orderInfo.orderStatus == 5" class="detail-font2">
						<view class="left">申请售后时间:</view>
						<view class="right">{{orderInfo.afterStartTime}}</view>
					</view>
					
					<!-- 一下均是 后台返回展示不返回不展示 -->
					<view v-if="orderInfo.afterEndTime != null" class="detail-font2">
						<view class="left">售后完成时间:</view>
						<view class="right">{{orderInfo.afterEndTime}}</view>
					</view>
					<view v-if="orderInfo.shopFeedbackTime != null" class="detail-font2">
						<view class="left">商家反馈时间:</view>
						<view class="right">{{orderInfo.shopFeedbackTime}}</view>
					</view>
					<view v-if="orderInfo.userCancelTime != null" class="detail-font2">
						<view class="left">用户取消时间:</view>
						<view class="right">{{orderInfo.userCancelTime}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view style="height: 120rpx;"></view>
		<!-- 底部按钮 -->
		<view class="order-bottom" >
			<view class="goods-bottom-r">
				<view v-if="orderInfo.orderStatus == 1&& orderInfo.serviceStartTime"
				@click="goJiaZhong(orderInfo.id)" class="goods-bottom-but">加钟</view>
				<view v-if="orderInfo.orderStatus == 0||orderInfo.orderStatus == 1||orderInfo.orderStatus ==2"
				class="goods-bottom-but" @click.stop="goTui(orderInfo.id,orderInfo.version)">申请退款</view>
				
				<view v-if="orderInfo.orderStatus == 4 && !isShenhe" 
				@click="goComment(orderInfo.id)" class="goods-bottom-but">评价</view>
				
				<view v-if="orderInfo.orderStatus == 3" @click="openModal" class="goods-bottom-but">取消售后</view>
			</view>
		</view>
	</view>

</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'
	
	export default {
		data() {
			return {
				isShenhe: 1,
				id: null,
				orderInfo: null,
				refundOption:"测试"
			}
		},
		components: { TopHeigth },
		onLoad(e) {
			this.id = e.id
			this.getOrder()
			uni.$u.http.post('/api/shop/v1_0/linyue/version',{}).then((res) => {
				this.isShenhe = !res.data
			})
		},
		methods: {
			setUrlFn(refundOption){
				if(this.orderInfo.refundOption==1){
					this.refundOption="联系不上技师/商家"
				}else if(this.orderInfo.refundOption==2){
					this.refundOption="技师爽约迟到"
				}else if(this.orderInfo.refundOption=='3'){
					this.refundOption='不想要了/买多了'
				}else if(this.orderInfo.refundOption==4){
					this.refundOption="与技师/商家协商一致"
				}else if(this.orderInfo.refundOption==2){
					this.refundOption="自己临时有事"
				}else{
					this.refundOption="自己临时有事"
				}
			},
			getOrder(type) {
				uni.$u.http.post('/api/shop/v1_0/tAppOrderRCA/turnTAppOrderInfo',{
						id: this.id
				}).then((res) => {
					this.orderInfo = res.data;
					this.setUrlFn(res.data.refundOption)
					
				}) 
			},
			goJiaZhong(){
				uni.navigateTo({
					url: "/pages/mine/TwoOrder?id="+ this.id +"&version="+this.version
				})
			},
			/* 申请退款 */
			goTui(id,version){
				uni.navigateTo({
					url: "/pages/mine/service?id="+ id +"&version="+version
				})
			},
			goComment(id){
				uni.navigateTo({
					url: "/pages/mine/assess?id="+ id
				})
			},
			openModal() {
				this.$refs.modal.open();
			},
			confirm() { //取消售后
				uni.$u.http.post('/api/shop/v1_0/tAppOrderRCA/cancelTAppOrderAfter',{
						id:this.orderInfo.id,
						version:this.orderInfo.version,
				}).then((res) => {
					this.getOrder()
					//this.orderInfo = res.data
				}) 
				console.log('点击确认按钮');
			}
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	
	
	.complaint{
		.list{
			@include flex;
			align-items: center;
			justify-content:space-between;
			padding:28rpx 0;
			.go{
				width: 32rpx;
				height: 32rpx;
			}
			.list-l{
				@include flex;
				align-items: center;
				justify-content:flex-start;
				font-size: 30rpx;
				.icon{
					width: 40rpx;
					height: 40rpx;
				}
				span{
					margin-left: 16rpx;
				}
				
			}
		}
	}
	
	.img-b{
		@include flex;
		width: 200rpx;
		height: 200rpx;
	}
	.money-box{
		@include flex;
		align-items: end;
		justify-content:flex-start;
		font-size: 24rpx;
		.red{
			color: #F82727;
			font-size: 34rpx;
			font-weight: bold;
			margin-right: 16rpx;
			span{
				font-size: 26rpx;
			}
		}
	}
	
	.complaint-top{
		@include flex;
		align-items: center;
		justify-content:space-between;
		.complaint-top-img{
			@include flex;
			align-items: center;
			justify-content:flex-start;
			font-size: 26rpx;
			.img{
				border-radius: 40rpx;
				overflow: hidden;
				font-weight: bold;
				color: #333;
				margin-right: 16rpx;
				image{
					width: 40rpx;
					height: 40rpx;
				}
			}
		}
		.complaint-top-r{
			font-size: 24rpx;
			color: #999;
		}
	}
	.goods-bottom{
		@include flex;
		align-items: center;
		justify-content:space-between;
		.goods-bottom-r{
			@include flex;
			align-items: center;
			justify-content:space-between;
		}
		.goods-bottom-but{
			width: 136rpx;
			height: 56rpx;
			line-height: 56rpx;
			font-size: 24rpx;
			color: #333;
			border: 2rpx solid #CBCBCB;
			border-radius:56rpx;
			text-align: center;
			margin-left: 16rpx;
		}
	}
	
	.time-top{
		@include flex;
		align-content: space-between;
		width: 100%;
		padding-top: 20rpx;
		.title-font{
			font-size: 30rpx;
			color: #333;
			text-align: center;
			padding-bottom: 16rpx;
			margin-right: 56rpx;
		}
		.choose{
			font-weight: bold;
			background: url("/static/image/title-line.png") no-repeat bottom center;
		}
	}
	
	/* --------------- */
	.detail-font{
		@include flex;
		align-items: center;
		justify-content:space-between;
		font-size: 24rpx;
		margin-bottom: 32rpx;
		.left{
			color: #999999;
		}
		.right{
			color: #333;
		}
	}
	.detail-font2{
		@include flex;
		align-items: center;
		justify-content:flex-start; 
		font-size: 24rpx;
		margin-bottom: 32rpx;
		.left{
			width: 170rpx;
			color: #999999;
		}
		.right{
			color: #333;
		}
	}
	.order-bottom{
		padding: 0 32rpx;
		background: #fff;
		position: fixed;
		bottom: 0;
		width: calc(100% - 64rpx);
		/* height: 100rpx; */
		
		@include flex;
		align-items: center;
		justify-content:flex-end; 
		.goods-bottom-r{
			@include flex;
			align-items: center;
			justify-content:space-between;
			.goods-bottom-but{
				width: 136rpx;
				height: 56rpx;
				line-height: 56rpx;
				font-size: 24rpx;
				color: #333;
				border: 2rpx solid #CBCBCB;
				border-radius:56rpx;
				text-align: center;
				margin-left: 16rpx;
				margin-top:26rpx;
				margin-bottom:26rpx;
			}
		}
		
	}
	::deep .uv-modal__content__text{
		text-align: center;
	}
	
	
	/* 公共复制过来的 */
	/* 商品 */
	.goods-box{
		.goods{
			display: flex;
			align-items: center;
			justify-content: flex-start;
			padding:32rpx 0;
			border-bottom: 2rpx solid #EEEEEE;
			.img-box{
				width:160rpx;
				height: 160rpx;
				border-radius:20rpx;
				margin-right: 24rpx;
				background:#f8f8f8;
				overflow: hidden;
				display: flex;
				align-items: center;
				.img{
					width: 160rpx;
					height: 160rpx;
				}
			}
			
			.goods-font{
				width:calc(100% - 184rpx);
				.goods-h1{
					font-size:30rpx;
					font-weight: bold;
					text-overflow: ellipsis;
					white-space: nowrap;
					overflow: hidden;
					margin-bottom: 8rpx;
				}
				.sale{
					font-size: 24rpx;
					color: #999;
					margin-bottom: 24rpx;
				}
				.font-bottom{
					display: flex;
					align-items: flex-end;
					justify-content:space-between;
					.font-bottom-l{
						display: flex;
						align-items: flex-end;
						justify-content: flex-start;
						.goods-span-red{
							font-size: 24rpx;
						}
						.red{
							color: #F82727;
							font-size: 34rpx;
							font-weight: bold;
							margin-right: 16rpx;
							span{
								
							}
						}
						.grey{
							color: #999;
							font-size: 24rpx;
						}
						.grey2{
							color: #999;
							font-size: 24rpx;
							text-decoration:line-through;
						}
					}
				}
			}
		}
		.goods:last-child{
			border-bottom: none;
		}
	}
</style>
